package gatech.cs2340.adventuretime.servlets;
import java.sql.Connection;
import java.sql.SQLException;
import 


public interface IRecord {

	/**
	 * Static method that creates a row for the IRecord rec in the appropriate table
	 * 
	 * @param rec
	 * 		An IRecord object to create a row for
	 * @param conn
	 * 		The connection to the database
	 * @throws SQLException
	 * 		If something goes wrong
	 */
	public void CreateRecord(IRecord rec, Connection conn) throws SQLException;
	
	/**
	 * A static method that instantiates a data-storing class from the database
	 * 
	 * @param key
	 * 		The unique key for the record (ex. the username for an user)
	 * @param conn
	 * 		The connection to the database
	 * @return
	 * 		An instantiated record
	 * @throws SQLException
	 * 		If something goes wrong
	 */
	public IRecord RetreiveRecord(String key, Connection conn) throws SQLException;
	
	/**
	 * Static method that updates a row in the database corresponding to the data-storing class.
	 * If the row does not exist, throws a SQLException
	 * @param rec
	 * 		An IRecord object to create a row for
	 * @param conn
	 * 		The connection to the database
	 * @throws SQLException
	 */
	public void UpdateRecord(IRecord rec, Connection conn) throws SQLException;
	
	/**
	 * Static method to delete the row in the database corresponding to the data-storing class rec.
	 * If the row does not exist, throws a SQLException
	 * @param rec
	 * 		An IRecord object to delete the row for
	 * @param conn
	 * 		The connection to the database
	 * @throws SQLException
	 * 		If the row corresponding to rec does not exist
	 */
	public void DeleteRecord(IRecord rec, Connection conn) throws SQLException;
}
